﻿using UnityEngine;
using System.Collections;

public class shoot : MonoBehaviour {
	public GameObject Ball;
	public float startspeed=0.0f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		if ((Kamera.turn==false && gameObject.name == "Shoot1") || (Kamera.turn==true && gameObject.name == "Shoot2"))
		{
			///if(started==false)
			{
				
				
				if(Input.GetKey("space"))
				{
					startspeed+=Time.deltaTime*2.5f;
				}

			}




			if(Input.GetKeyUp ("space"))
			{

				for(int i=0; i<=2; i++)
				{
				GameObject clone;
				clone=Instantiate(Ball, transform.position, transform.rotation)as GameObject;

				clone.rigidbody.velocity=transform.right*(-40-Random.Range(0.0f,10.0f))*startspeed;
					clone.transform.position+=transform.right*-1.5f*i;
				Destroy(clone,10.0f);

				}
				startspeed=0.0f;

			}


		}
	}
}
